createAttributionContext

open fun createAttributionContext(@NonNull context: Context, @Nullable attributionTag: String): Context(source)

Return a new Context object for the current Context but attribute to a different tag. In complex apps attribution tagging can be used to distinguish between separate logical parts.

Compatibility behavior:

  • API 30 and above, returns a new Context object with the specified attribution tag
  • API 29 and earlier, returns the original context with no attribution tag

Return

A Context that is tagged for the new attribution

Parameters

context

The current context.

attributionTag

The tag or null to create a context for the default.

See also